Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / core / testing / src / commonMain / kotlin / org / meshtastic / core / testing / FakeQuickChatActionRepository.kt

Displaying Raw • Download

core/testing/src/commonMain/kotlin/org/meshtastic/core/testing/FakeQuickChatActionRepository.kt 41414f832f938b655c97bc07509bc140ea16e2a3 (41414f83) Text, 2.67 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.testing

Tff7b72import T7ee787kotlinx.coroutines.flow.Flow
Tff7b72import T7ee787org.meshtastic.core.database.entity.QuickChatAction
Tff7b72import T7ee787org.meshtastic.core.repository.QuickChatActionRepository

T8b949e/**
* A test double for [QuickChatActionRepository] that keeps actions in an in-memory list (sorted by `position`).
*
* The in-memory list is exposed reactively through [getAllActions].
*/
Tff7b72class T56d364FakeQuickChatActionRepository Tb4b4b4:
Te6edf3BaseFakeTb4b4b4(Tb4b4b4)Tb4b4b4,
Te6edf3QuickChatActionRepository Tb4b4b4{

Tff7b72private Tff7b72val Te6edf3actionsFlow Tff7b72= Te6edf3mutableStateFlowTff7b72<Te6edf3ListTff7b72<Te6edf3QuickChatActionTff7b72>Tff7b72>Tb4b4b4(Te6edf3emptyListTb4b4b4(Tb4b4b4)Tb4b4b4)

Tff7b72override Tff7b72fun Td2a8ffgetAllActionsTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Te6edf3ListTff7b72<Te6edf3QuickChatActionTff7b72>Tff7b72> Tff7b72= Te6edf3actionsFlow

Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffupsertTb4b4b4(Te6edf3actionTb4b4b4: Te6edf3QuickChatActionTb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3existingIndex Tff7b72= Te6edf3actionsFlowTb4b4b4.Te6edf3valueTb4b4b4.Te6edf3indexOfFirst Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3uuid Tff7b72=Tff7b72= Te6edf3actionTb4b4b4.Te6edf3uuid Tb4b4b4}
Te6edf3actionsFlowTb4b4b4.Te6edf3value Tff7b72=
Tff7b72if Tb4b4b4(Te6edf3existingIndex Tff7b72>Tff7b72= T79c0ff0Tb4b4b4) Tb4b4b4{
Te6edf3actionsFlowTb4b4b4.Te6edf3valueTb4b4b4.Te6edf3toMutableListTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3also Tb4b4b4{ Tffa657itTff7b72[Te6edf3existingIndexTff7b72] Tff7b72= Te6edf3action Tb4b4b4}
Tb4b4b4} Tff7b72else Tb4b4b4{
Te6edf3actionsFlowTb4b4b4.Te6edf3value Tff7b72+ Te6edf3action
Tb4b4b4}
Tb4b4b4.Te6edf3sortedBy Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3position Tb4b4b4}
Tb4b4b4}

Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffdeleteAllTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3actionsFlowTb4b4b4.Te6edf3value Tff7b72= Te6edf3emptyListTb4b4b4(Tb4b4b4)
Tb4b4b4}

Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffdeleteTb4b4b4(Te6edf3actionTb4b4b4: Te6edf3QuickChatActionTb4b4b4) Tb4b4b4{
Te6edf3actionsFlowTb4b4b4.Te6edf3value Tff7b72=
Te6edf3actionsFlowTb4b4b4.Te6edf3value
Tb4b4b4.Te6edf3filterNot Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3uuid Tff7b72=Tff7b72= Te6edf3actionTb4b4b4.Te6edf3uuid Tb4b4b4}
Tb4b4b4.Te6edf3map Tb4b4b4{ Tff7b72if Tb4b4b4(Tffa657itTb4b4b4.Te6edf3position Tff7b72> Te6edf3actionTb4b4b4.Te6edf3positionTb4b4b4) Tffa657itTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3position Tff7b72= Tffa657itTb4b4b4.Te6edf3position Tff7b72- T79c0ff1Tb4b4b4) Tff7b72else Tffa657it Tb4b4b4}
Tb4b4b4}

Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffsetItemPositionTb4b4b4(Te6edf3uuidTb4b4b4: Tffa657LongTb4b4b4, Te6edf3newPosTb4b4b4: Tffa657IntTb4b4b4) Tb4b4b4{
Te6edf3actionsFlowTb4b4b4.Te6edf3value Tff7b72=
Te6edf3actionsFlowTb4b4b4.Te6edf3valueTb4b4b4.Te6edf3map Tb4b4b4{ Tff7b72if Tb4b4b4(Tffa657itTb4b4b4.Te6edf3uuid Tff7b72=Tff7b72= Te6edf3uuidTb4b4b4) Tffa657itTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3position Tff7b72= Te6edf3newPosTb4b4b4) Tff7b72else Tffa657it Tb4b4b4}Tb4b4b4.Te6edf3sortedBy Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3position Tb4b4b4}
Tb4b4b4}

T8b949e/** Seeds the current list of actions (useful for test setup). */
Tff7b72fun Td2a8ffsetActionsTb4b4b4(Te6edf3actionsTb4b4b4: Te6edf3ListTff7b72<Te6edf3QuickChatActionTff7b72>Tb4b4b4) Tb4b4b4{
Te6edf3actionsFlowTb4b4b4.Te6edf3value Tff7b72= Te6edf3actionsTb4b4b4.Te6edf3sortedBy Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3position Tb4b4b4}
Tb4b4b4}

T8b949e/** Returns the current in-memory snapshot. */
Tff7b72val Te6edf3currentActionsTb4b4b4: Te6edf3ListTff7b72<Te6edf3QuickChatActionTff7b72>
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3actionsFlowTb4b4b4.Te6edf3value
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.13s